/* eslint-disable @typescript-eslint/no-unused-vars */ // DO NOT EDIT THIS FILE. AUTO-GENERATED BY mobiletto-orm-typedef-gen import { H3Event } from "h3"; import { MobilettoOrmValidationErrors } from "mobiletto-orm-typedef"; import { LibraryType, LibraryTypeDef } from "yuebing-model"; export default defineEventHandler(async (event: H3Event) => { return await filterErrors(event, "library.create", async (event: H3Event) => { return await requireAdminAccountObject(event, "library.create", async (event: H3Event, session, account) => { const libraryRepo = libraryRepository(); const id = event?.context?.params?.id; if (!id) throw notFound(libraryRepo.typeDef.idFieldName()); const obj: LibraryType = await readBody(event); if (!obj) { throw badRequest(); } if (LibraryTypeDef.id(obj) !== id) { const errs: MobilettoOrmValidationErrors = {}; errs[libraryRepo.typeDef.idFieldName()] = ["mismatch"]; throw validationError(errs); } else { return await libraryRepo.create(obj); } }); }); });